<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>yadis.xrires</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="yadis-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://www.openidenabled.com/yadis/">Python-Yadis</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="yadis-module.html">Package&nbsp;yadis</a> ::
        Module&nbsp;xrires
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="yadis.xrires-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="yadis.xrires-module.html">Module yadis.xrires</a></h1>
<pre class="py-src">
<tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment"># -*- test-case-name: yadis.test.test_xrires -*-</tt> </tt>
<tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-docstring">"""XRI resolution.</tt> </tt>
<tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<tt class="py-lineno">  4</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">urllib</tt> <tt class="py-keyword">import</tt> <tt class="py-name">urlencode</tt> </tt>
<tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">urljr</tt> <tt class="py-keyword">import</tt> <tt class="py-name">fetchers</tt> </tt>
<tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Package yadis=yadis-module.html"><a title="yadis" class="py-name" href="#" onclick="return doclink('link-0', 'yadis', 'link-0');">yadis</a></tt></tt> <tt class="py-keyword">import</tt> <tt id="link-1" class="py-name" targets="Module yadis.etxrd=yadis.etxrd-module.html"><a title="yadis.etxrd" class="py-name" href="#" onclick="return doclink('link-1', 'etxrd', 'link-1');">etxrd</a></tt></tt> </tt>
<tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-2" class="py-name"><a title="yadis" class="py-name" href="#" onclick="return doclink('link-2', 'yadis', 'link-0');">yadis</a></tt></tt><tt class="py-op">.</tt><tt id="link-3" class="py-name" targets="Module yadis.xri=yadis.xri-module.html"><a title="yadis.xri" class="py-name" href="#" onclick="return doclink('link-3', 'xri', 'link-3');">xri</a></tt></tt> <tt class="py-keyword">import</tt> <tt id="link-4" class="py-name" targets="Function yadis.xri.toURINormal()=yadis.xri-module.html#toURINormal"><a title="yadis.xri.toURINormal" class="py-name" href="#" onclick="return doclink('link-4', 'toURINormal', 'link-4');">toURINormal</a></tt></tt> </tt>
<tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-5" class="py-name"><a title="yadis" class="py-name" href="#" onclick="return doclink('link-5', 'yadis', 'link-0');">yadis</a></tt></tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Module yadis.services=yadis.services-module.html"><a title="yadis.services" class="py-name" href="#" onclick="return doclink('link-6', 'services', 'link-6');">services</a></tt></tt> <tt class="py-keyword">import</tt> <tt id="link-7" class="py-name" targets="Function yadis.etxrd.iterServices()=yadis.etxrd-module.html#iterServices"><a title="yadis.etxrd.iterServices" class="py-name" href="#" onclick="return doclink('link-7', 'iterServices', 'link-7');">iterServices</a></tt></tt> </tt>
<tt class="py-lineno"> 10</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt id="link-8" class="py-name" targets="Variable yadis.xrires.DEFAULT_PROXY=yadis.xrires-module.html#DEFAULT_PROXY"><a title="yadis.xrires.DEFAULT_PROXY" class="py-name" href="#" onclick="return doclink('link-8', 'DEFAULT_PROXY', 'link-8');">DEFAULT_PROXY</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-string">'http://proxy.xri.net/'</tt> </tt>
<tt class="py-lineno"> 12</tt>  <tt class="py-line"> </tt>
<a name="ProxyResolver"></a><div id="ProxyResolver-def"><tt class="py-lineno"> 13</tt> <a class="py-toggle" href="#" id="ProxyResolver-toggle" onclick="return toggle('ProxyResolver');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="yadis.xrires.ProxyResolver-class.html">ProxyResolver</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ProxyResolver-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="ProxyResolver-expanded"><tt class="py-lineno"> 14</tt>  <tt class="py-line">    <tt class="py-docstring">"""Python interface to a remote XRI proxy resolver.</tt> </tt>
<tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="ProxyResolver.__init__"></a><div id="ProxyResolver.__init__-def"><tt class="py-lineno"> 16</tt> <a class="py-toggle" href="#" id="ProxyResolver.__init__-toggle" onclick="return toggle('ProxyResolver.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="yadis.xrires.ProxyResolver-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">proxy_url</tt><tt class="py-op">=</tt><tt id="link-9" class="py-name"><a title="yadis.xrires.DEFAULT_PROXY" class="py-name" href="#" onclick="return doclink('link-9', 'DEFAULT_PROXY', 'link-8');">DEFAULT_PROXY</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ProxyResolver.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ProxyResolver.__init__-expanded"><tt class="py-lineno"> 17</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">proxy_url</tt> <tt class="py-op">=</tt> <tt class="py-name">proxy_url</tt> </tt>
</div><tt class="py-lineno"> 18</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 19</tt>  <tt class="py-line"> </tt>
<a name="ProxyResolver.queryURL"></a><div id="ProxyResolver.queryURL-def"><tt class="py-lineno"> 20</tt> <a class="py-toggle" href="#" id="ProxyResolver.queryURL-toggle" onclick="return toggle('ProxyResolver.queryURL');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="yadis.xrires.ProxyResolver-class.html#queryURL">queryURL</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">xri</tt><tt class="py-op">,</tt> <tt class="py-param">service_type</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ProxyResolver.queryURL-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ProxyResolver.queryURL-expanded"><tt class="py-lineno"> 21</tt>  <tt class="py-line">        <tt class="py-docstring">"""Build a URL to query the proxy resolver.</tt> </tt>
<tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-docstring">        @param xri: An XRI to resolve.</tt> </tt>
<tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-docstring">        @type xri: unicode</tt> </tt>
<tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt class="py-docstring">        @param service_type: The service type to resolve, if you desire</tt> </tt>
<tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-docstring">            service endpoint selection.  A service type is a URI.</tt> </tt>
<tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-docstring">        @type service_type: str</tt> </tt>
<tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 30</tt>  <tt class="py-line"><tt class="py-docstring">        @returns: a URL</tt> </tt>
<tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-docstring">        @returntype: str</tt> </tt>
<tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<tt class="py-lineno"> 33</tt>  <tt class="py-line">        <tt class="py-comment"># Trim off the xri:// prefix.  The proxy resolver didn't accept it</tt> </tt>
<tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment"># when this code was written, but that may (or may not) change for</tt> </tt>
<tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment"># XRI Resolution 2.0 Working Draft 11.</tt> </tt>
<tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-name">qxri</tt> <tt class="py-op">=</tt> <tt id="link-10" class="py-name"><a title="yadis.xri.toURINormal" class="py-name" href="#" onclick="return doclink('link-10', 'toURINormal', 'link-4');">toURINormal</a></tt></tt><tt class="py-op">(</tt><tt id="link-11" class="py-name"><a title="yadis.xri" class="py-name" href="#" onclick="return doclink('link-11', 'xri', 'link-3');">xri</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">6</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 37</tt>  <tt class="py-line">        <tt class="py-name">hxri</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">proxy_url</tt> <tt class="py-op">+</tt> <tt class="py-name">qxri</tt> </tt>
<tt class="py-lineno"> 38</tt>  <tt class="py-line">        <tt class="py-name">args</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt> </tt>
<tt class="py-lineno"> 39</tt>  <tt class="py-line">            <tt class="py-comment"># XXX: If the proxy resolver will ensure that it doesn't return</tt> </tt>
<tt class="py-lineno"> 40</tt>  <tt class="py-line">            <tt class="py-comment"># bogus CanonicalIDs (as per Steve's message of 15 Aug 2006</tt> </tt>
<tt class="py-lineno"> 41</tt>  <tt class="py-line">            <tt class="py-comment"># 11:13:42), then we could ask for application/xrd+xml instead,</tt> </tt>
<tt class="py-lineno"> 42</tt>  <tt class="py-line">            <tt class="py-comment"># which would give us a bit less to process.</tt> </tt>
<tt class="py-lineno"> 43</tt>  <tt class="py-line">            <tt class="py-string">'_xrd_r'</tt><tt class="py-op">:</tt> <tt class="py-string">'application/xrds+xml'</tt><tt class="py-op">,</tt> </tt>
<tt class="py-lineno"> 44</tt>  <tt class="py-line">            <tt class="py-op">}</tt> </tt>
<tt class="py-lineno"> 45</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">service_type</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 46</tt>  <tt class="py-line">            <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-string">'_xrd_t'</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">service_type</tt> </tt>
<tt class="py-lineno"> 47</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 48</tt>  <tt class="py-line">            <tt class="py-comment"># Don't perform service endpoint selection.</tt> </tt>
<tt class="py-lineno"> 49</tt>  <tt class="py-line"><tt class="py-comment"></tt>            <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-string">'_xrd_r'</tt><tt class="py-op">]</tt> <tt class="py-op">+=</tt> <tt class="py-string">';sep=false'</tt> </tt>
<tt class="py-lineno"> 50</tt>  <tt class="py-line">        <tt id="link-12" class="py-name" targets="Method yadis.xrires.ProxyResolver.query()=yadis.xrires.ProxyResolver-class.html#query"><a title="yadis.xrires.ProxyResolver.query" class="py-name" href="#" onclick="return doclink('link-12', 'query', 'link-12');">query</a></tt></tt> <tt class="py-op">=</tt> <tt id="link-13" class="py-name" targets="Function yadis.xrires._appendArgs()=yadis.xrires-module.html#_appendArgs"><a title="yadis.xrires._appendArgs" class="py-name" href="#" onclick="return doclink('link-13', '_appendArgs', 'link-13');">_appendArgs</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">hxri</tt><tt class="py-op">,</tt> <tt class="py-name">args</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 51</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-14" class="py-name"><a title="yadis.xrires.ProxyResolver.query" class="py-name" href="#" onclick="return doclink('link-14', 'query', 'link-12');">query</a></tt></tt> </tt>
</div><tt class="py-lineno"> 52</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 53</tt>  <tt class="py-line"> </tt>
<a name="ProxyResolver.query"></a><div id="ProxyResolver.query-def"><tt class="py-lineno"> 54</tt> <a class="py-toggle" href="#" id="ProxyResolver.query-toggle" onclick="return toggle('ProxyResolver.query');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="yadis.xrires.ProxyResolver-class.html#query">query</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">xri</tt><tt class="py-op">,</tt> <tt class="py-param">service_types</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ProxyResolver.query-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ProxyResolver.query-expanded"><tt class="py-lineno"> 55</tt>  <tt class="py-line">        <tt class="py-docstring">"""Resolve some services for an XRI.</tt> </tt>
<tt class="py-lineno"> 56</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 57</tt>  <tt class="py-line"><tt class="py-docstring">        Note: I don't implement any service endpoint selection beyond what</tt> </tt>
<tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-docstring">        the resolver I'm querying does, so the Services I return may well</tt> </tt>
<tt class="py-lineno"> 59</tt>  <tt class="py-line"><tt class="py-docstring">        include Services that were not of the types you asked for.</tt> </tt>
<tt class="py-lineno"> 60</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 61</tt>  <tt class="py-line"><tt class="py-docstring">        May raise fetchers.HTTPFetchingError or L{etxrd.XRDError} if</tt> </tt>
<tt class="py-lineno"> 62</tt>  <tt class="py-line"><tt class="py-docstring">        the fetching or parsing don't go so well.</tt> </tt>
<tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 64</tt>  <tt class="py-line"><tt class="py-docstring">        @param xri: An XRI to resolve.</tt> </tt>
<tt class="py-lineno"> 65</tt>  <tt class="py-line"><tt class="py-docstring">        @type xri: unicode</tt> </tt>
<tt class="py-lineno"> 66</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 67</tt>  <tt class="py-line"><tt class="py-docstring">        @param service_types: A list of services types to query for.  Service</tt> </tt>
<tt class="py-lineno"> 68</tt>  <tt class="py-line"><tt class="py-docstring">            types are URIs.</tt> </tt>
<tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-docstring">        @type service_types: list of str</tt> </tt>
<tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<tt class="py-lineno"> 71</tt>  <tt class="py-line"><tt class="py-docstring">        @returns: tuple of (CanonicalID, Service elements)</tt> </tt>
<tt class="py-lineno"> 72</tt>  <tt class="py-line"><tt class="py-docstring">        @returntype: (unicode, list of C{ElementTree.Element}s)</tt> </tt>
<tt class="py-lineno"> 73</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-comment"># FIXME: No test coverage!</tt> </tt>
<tt class="py-lineno"> 75</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt id="link-15" class="py-name"><a title="yadis.services" class="py-name" href="#" onclick="return doclink('link-15', 'services', 'link-6');">services</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 76</tt>  <tt class="py-line">        <tt class="py-comment"># Make a seperate request to the proxy resolver for each service</tt> </tt>
<tt class="py-lineno"> 77</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment"># type, as, if it is following Refs, it could return a different</tt> </tt>
<tt class="py-lineno"> 78</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment"># XRDS for each.</tt> </tt>
<tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-keyword">for</tt> <tt class="py-name">service_type</tt> <tt class="py-keyword">in</tt> <tt class="py-name">service_types</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 80</tt>  <tt class="py-line">            <tt class="py-name">url</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name" targets="Method yadis.xrires.ProxyResolver.queryURL()=yadis.xrires.ProxyResolver-class.html#queryURL"><a title="yadis.xrires.ProxyResolver.queryURL" class="py-name" href="#" onclick="return doclink('link-16', 'queryURL', 'link-16');">queryURL</a></tt></tt><tt class="py-op">(</tt><tt id="link-17" class="py-name"><a title="yadis.xri" class="py-name" href="#" onclick="return doclink('link-17', 'xri', 'link-3');">xri</a></tt></tt><tt class="py-op">,</tt> <tt class="py-name">service_type</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 81</tt>  <tt class="py-line">            <tt class="py-name">response</tt> <tt class="py-op">=</tt> <tt class="py-name">fetchers</tt><tt class="py-op">.</tt><tt id="link-18" class="py-name" targets="Method yadis.test.test_discover.TestFetcher.fetch()=yadis.test.test_discover.TestFetcher-class.html#fetch,Method yadis.test.test_discover.TestSecondGet.MockFetcher.fetch()=yadis.test.test_discover.TestSecondGet.MockFetcher-class.html#fetch"><a title="yadis.test.test_discover.TestFetcher.fetch
yadis.test.test_discover.TestSecondGet.MockFetcher.fetch" class="py-name" href="#" onclick="return doclink('link-18', 'fetch', 'link-18');">fetch</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">url</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 82</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">response</tt><tt class="py-op">.</tt><tt class="py-name">status</tt> <tt class="py-op">!=</tt> <tt class="py-number">200</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 83</tt>  <tt class="py-line">                <tt class="py-comment"># XXX: sucks to fail silently.</tt> </tt>
<tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-comment"></tt>                <tt class="py-comment"># print "response not OK:", response</tt> </tt>
<tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-comment"></tt>                <tt class="py-keyword">continue</tt> </tt>
<tt class="py-lineno"> 86</tt>  <tt class="py-line">            <tt class="py-name">et</tt> <tt class="py-op">=</tt> <tt id="link-19" class="py-name"><a title="yadis.etxrd" class="py-name" href="#" onclick="return doclink('link-19', 'etxrd', 'link-1');">etxrd</a></tt></tt><tt class="py-op">.</tt><tt id="link-20" class="py-name" targets="Function yadis.etxrd.parseXRDS()=yadis.etxrd-module.html#parseXRDS"><a title="yadis.etxrd.parseXRDS" class="py-name" href="#" onclick="return doclink('link-20', 'parseXRDS', 'link-20');">parseXRDS</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">response</tt><tt class="py-op">.</tt><tt class="py-name">body</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 87</tt>  <tt class="py-line">            <tt class="py-name">canonicalID</tt> <tt class="py-op">=</tt> <tt id="link-21" class="py-name"><a title="yadis.etxrd" class="py-name" href="#" onclick="return doclink('link-21', 'etxrd', 'link-1');">etxrd</a></tt></tt><tt class="py-op">.</tt><tt id="link-22" class="py-name" targets="Function yadis.etxrd.getCanonicalID()=yadis.etxrd-module.html#getCanonicalID"><a title="yadis.etxrd.getCanonicalID" class="py-name" href="#" onclick="return doclink('link-22', 'getCanonicalID', 'link-22');">getCanonicalID</a></tt></tt><tt class="py-op">(</tt><tt id="link-23" class="py-name"><a title="yadis.xri" class="py-name" href="#" onclick="return doclink('link-23', 'xri', 'link-3');">xri</a></tt></tt><tt class="py-op">,</tt> <tt class="py-name">et</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 88</tt>  <tt class="py-line">            <tt class="py-name">some_services</tt> <tt class="py-op">=</tt> <tt class="py-name">list</tt><tt class="py-op">(</tt><tt id="link-24" class="py-name"><a title="yadis.etxrd.iterServices" class="py-name" href="#" onclick="return doclink('link-24', 'iterServices', 'link-7');">iterServices</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">et</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 89</tt>  <tt class="py-line">            <tt id="link-25" class="py-name"><a title="yadis.services" class="py-name" href="#" onclick="return doclink('link-25', 'services', 'link-6');">services</a></tt></tt><tt class="py-op">.</tt><tt class="py-name">extend</tt><tt class="py-op">(</tt><tt class="py-name">some_services</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 90</tt>  <tt class="py-line">        <tt class="py-comment"># TODO:</tt> </tt>
<tt class="py-lineno"> 91</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment">#  * If we do get hits for multiple service_types, we're almost</tt> </tt>
<tt class="py-lineno"> 92</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment">#    certainly going to have duplicated service entries and</tt> </tt>
<tt class="py-lineno"> 93</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-comment">#    broken priority ordering.</tt> </tt>
<tt class="py-lineno"> 94</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-keyword">return</tt> <tt class="py-name">canonicalID</tt><tt class="py-op">,</tt> <tt id="link-26" class="py-name"><a title="yadis.services" class="py-name" href="#" onclick="return doclink('link-26', 'services', 'link-6');">services</a></tt></tt> </tt>
</div></div><tt class="py-lineno"> 95</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 96</tt>  <tt class="py-line"> </tt>
<a name="_appendArgs"></a><div id="_appendArgs-def"><tt class="py-lineno"> 97</tt> <a class="py-toggle" href="#" id="_appendArgs-toggle" onclick="return toggle('_appendArgs');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="yadis.xrires-module.html#_appendArgs">_appendArgs</a><tt class="py-op">(</tt><tt class="py-param">url</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_appendArgs-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_appendArgs-expanded"><tt class="py-lineno"> 98</tt>  <tt class="py-line">    <tt class="py-docstring">"""Append some arguments to an HTTP query.</tt> </tt>
<tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<tt class="py-lineno">100</tt>  <tt class="py-line">    <tt class="py-comment"># to be merged with oidutil.appendArgs when we combine the projects.</tt> </tt>
<tt class="py-lineno">101</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-keyword">if</tt> <tt class="py-name">hasattr</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">,</tt> <tt class="py-string">'items'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">102</tt>  <tt class="py-line">        <tt class="py-name">args</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno">103</tt>  <tt class="py-line">        <tt class="py-name">args</tt><tt class="py-op">.</tt><tt class="py-name">sort</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno">104</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">105</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">106</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">url</tt> </tt>
<tt class="py-lineno">107</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">108</tt>  <tt class="py-line">    <tt class="py-comment"># According to XRI Resolution section "QXRI query parameters":</tt> </tt>
<tt class="py-lineno">109</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-comment">#</tt> </tt>
<tt class="py-lineno">110</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-comment"># """If the original QXRI had a null query component (only a leading</tt> </tt>
<tt class="py-lineno">111</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-comment">#    question mark), or a query component consisting of only question</tt> </tt>
<tt class="py-lineno">112</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-comment">#    marks, one additional leading question mark MUST be added when</tt> </tt>
<tt class="py-lineno">113</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-comment">#    adding any XRI resolution parameters."""</tt> </tt>
<tt class="py-lineno">114</tt>  <tt class="py-line"><tt class="py-comment"></tt> </tt>
<tt class="py-lineno">115</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-string">'?'</tt> <tt class="py-keyword">in</tt> <tt class="py-name">url</tt><tt class="py-op">.</tt><tt class="py-name">rstrip</tt><tt class="py-op">(</tt><tt class="py-string">'?'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">116</tt>  <tt class="py-line">        <tt class="py-name">sep</tt> <tt class="py-op">=</tt> <tt class="py-string">'&amp;'</tt> </tt>
<tt class="py-lineno">117</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">118</tt>  <tt class="py-line">        <tt class="py-name">sep</tt> <tt class="py-op">=</tt> <tt class="py-string">'?'</tt> </tt>
<tt class="py-lineno">119</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">120</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-string">'%s%s%s'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">url</tt><tt class="py-op">,</tt> <tt class="py-name">sep</tt><tt class="py-op">,</tt> <tt class="py-name">urlencode</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><tt class="py-lineno">121</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="yadis-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://www.openidenabled.com/yadis/">Python-Yadis</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">Generated by Epydoc
        3.0alpha3 on Fri Dec  8 13:17:18 2006</td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
